﻿/***********************************************************************
 * <copyright file="Mapper.cs" company="BUCA JSC">
 * -->    Copyright (C) statement. All right reserved
 * </copyright>
 * 
 * Created:   Tuanhm
 * Email:    Tuanhm@humg@gmail.com
 * Website:
 * Create Date: Thursday, March 27, 2014
 * Usage: 
 * 
 * RevisionHistory: 
 * Date         Author               Description 
 * 
 * ************************************************************************/

using System.Collections.Generic;
using System.Linq;
using WindowsForms.AOnline.Model.AccountingServiceReference;
//using WindowsForms.AOnline.Model.ActionAccountingServiceReference;
using WindowsForms.AOnline.Model.BusinessObjects.Dictionary;
using WindowsForms.AOnline.Model.BusinessObjects.Report;
using WindowsForms.AOnline.Model.BusinessObjects.Report.Stock;

namespace WindowsForms.AOnline.Model.DataTransferObjectMapper
{
    /// <summary>
    /// Class Mapper.
    /// </summary>
    public class Mapper
    {

        #region ToDataTransferObjects

        /// <summary>to
        /// To the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<DepartmentDto> ToDataTransferObjects(IEnumerable<DepartmentModel> c)
        {
            return c == null ? null : c.Select(source => ToDataTransferObject((source))).ToList();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static IList<UnitDto> ToDataTransferObjects(IEnumerable<UnitModel> c)
        {
            return c == null ? null : c.Select(source => ToDataTransferObject((source))).ToList();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static IList<CustomerDto> ToDataTransferObjects(IEnumerable<CustomerModel> c)
        {
            return c == null ? null : c.Select(source => ToDataTransferObject((source))).ToList();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static IList<VendorDto> ToDataTransferObjects(IEnumerable<VendorModel> c)
        {
            return c == null ? null : c.Select(source => ToDataTransferObject((source))).ToList();
        }


        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static IList<VoucherTypeDto> ToDataTransferObjects(IEnumerable<VoucherTypeModel> c)
        {
            return c == null ? null : c.Select(source => ToDataTransferObject((source))).ToList();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static IList<RefTypeDto> ToDataTransferObjects(IEnumerable<RefTypeModel> c)
        {
            return c == null ? null : c.Select(source => ToDataTransferObject((source))).ToList();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="dbOptions"></param>
        /// <returns></returns>
        public static IList<AutoBusinessDto> ToDataTransferObjects(IEnumerable<AutoBusinessModel> c)
        {
            return c == null ? null : c.Select(source => ToDataTransferObject((source))).ToList();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="dbOptions"></param>
        /// <returns></returns>
        public static DbOptionDto[] ToDataTransferObjects(IEnumerable<DbOptionModel> c)
        {
            return c == null ? null : c.Select(source => ToDataTransferObject((source))).ToArray();
        }

        /// <summary>to
        /// To the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<StockDto> ToDataTransferObjects(IEnumerable<StockModel> c)
        {
            return c == null ? null : c.Select(source => ToDataTransferObject((source))).ToList();
        }

        /// <summary>to
        /// To the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<InventoryItemDto> ToDataTransferObjects(IEnumerable<InventoryItemModel> c)
        {
            return c == null ? null : c.Select(source => ToDataTransferObject((source))).ToList();
        }

        /// <summary>to
        /// To the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<AccountDto> ToDataTransferObjects(IEnumerable<AccountModel> c)
        {
            return c == null ? null : c.Select(source => ToDataTransferObject((source))).ToList();
        }

       
        /// <summary>to
        /// To the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<EmployTestDto> ToDataTransferObjects(IEnumerable<EmployTestModel> c)
        {
            return c == null ? null : c.Select(source => ToDataTransferObject((source))).ToList();
        }

        /// <summary>to
        /// To the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<ReportListDto> ToDataTransferObjects(IEnumerable<ReportListModel> c)
        {
            return c == null ? null : c.Select(source => ToDataTransferObject((source))).ToList();
        }

        /// <summary>to
        /// To the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<ReportGroupDto> ToDataTransferObjects(IEnumerable<ReportGroupModel> c)
        {
            return c == null ? null : c.Select(source => ToDataTransferObject((source))).ToList();
        }
        /// <summary>to
        /// To the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<FixedAssetDto> ToDataTransferObjects(IEnumerable<FixedAssetModel> c)
        {
            return c == null ? null : c.Select(source => ToDataTransferObject((source))).ToList();
        }

        /// <summary>to
        /// To the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<FixedAssetCategoryDto> ToDataTransferObjects(IEnumerable<FixedAssetCategoryModel> c)
        {
            return c == null ? null : c.Select(source => ToDataTransferObject((source))).ToList();
        }
        #endregion

        #region ToDataTransferObject.

        /// <summary>
        /// 
        /// </summary>
        /// <param name="c"></param>
        /// <returns></returns>
        public static DepartmentDto ToDataTransferObject(DepartmentModel c)
        {
            if (c == null) return null;

            return new DepartmentDto
            {
                DepartmentId = c.DepartmentId,
                UnitId = c.UnitId,
                Code = c.Code,
                Name = c.Name,
                Address = c.Address,
                Description = c.Description,
                IsActive = c.IsActive,
                Fax = c.Fax,
                PhoneNumber = c.PhoneNumber,
                ParentId = c.ParentId,
            };
        }
        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <returns></returns>
        public static UnitDto ToDataTransferObject(UnitModel c)
        {
            if (c == null) return null;
            return new UnitDto
            {

                UnitId = c.UnitId,
                ParentId = c.ParentId,
                Code = c.Code,
                Name = c.Name,
                Grade = c.Grade,
                IsActive = c.IsActive,
                HasParent = c.HasParent,
                PhoneNumber = c.PhoneNumber,
                Address = c.Address,
                ByManagement = c.ByManagement,
            };
        }

        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <returns></returns>
        public static CustomerDto ToDataTransferObject(CustomerModel c)
        {
            return new CustomerDto
            {
                CustomerId = c.CustomerId,
                UnitId = c.UnitId,
                Code = c.Code,
                Name = c.Name,
                Address = c.Address,
                PhoneNumber = c.PhoneNumber,
                Fax = c.Fax,
                CompanyName = c.CompanyName,
                ContactName = c.ContactName,
                Description = c.Description,
                IsActive = c.IsActive,
            };
        }

        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <returns></returns>
        public static VendorDto ToDataTransferObject(VendorModel c)
        {
            return new VendorDto
            {
                VendorId = c.VendorId,
                Code = c.Code,
                Name = c.Name,
                Address = c.Address,
                ContactName = c.ContactName,
                PhoneNumber = c.PhoneNumber,
                Description = c.Description,
                Fax = c.Fax,
                IsActive = c.IsActive,
                UnitId = c.UnitId,
            };
        }


        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <returns></returns>
        public static VoucherTypeDto ToDataTransferObject(VoucherTypeModel c)
        {
            return new VoucherTypeDto
            {
                VoucherTypeId = c.VoucherTypeId,
                VoucherTypeName = c.VoucherTypeName,
                IsActive = c.IsActive
            };
        }

        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <returns></returns>
        public static RefTypeDto ToDataTransferObject(RefTypeModel c)
        {
            return new RefTypeDto
            {
                RefTypeId = c.RefTypeId,
                MasterTable = c.MasterTable,
                Name = c.Name,
                DetailTable = c.DetailTable,
                Description = c.Description,
                IsActive = c.IsActive,
            };
        }


        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        public static AutoBusinessDto ToDataTransferObject(AutoBusinessModel c)
        {
            return new AutoBusinessDto
            {
                AutoBusinessId = c.AutoBusinessId,
                AutoBusinessCode = c.AutoBusinessCode,
                AutoBusinessName = c.AutoBusinessName,
                RefTypeId = c.RefTypeId,
                VoucherTypeId = c.VoucherTypeId,
                DebitAccountNumber = c.DebitAccountNumber,
                CreditAccountNumber = c.CreditAccountNumber,
                //  BudgetItemCode = model.BudgetItemCode,
                //  BudgetSourceCode = model.BudgetSourceCode,
                Description = c.Description,
                IsActive = c.IsActive,
                UnitId = c.UnitId
            };
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="dbOption"></param>
        /// <returns></returns>
        public static DbOptionDto ToDataTransferObject(DbOptionModel dbOption)
        {
            if (dbOption == null) return null;

            return new DbOptionDto
            {
                OptionId = dbOption.OptionId,
                UnitId = dbOption.UnitId,
                Code = dbOption.Code,
                Value = dbOption.Value,
                ValueType = dbOption.ValueType,
                Description = dbOption.Description,
                IsSystem = dbOption.IsSystem
            };
        }

        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static StockDto ToDataTransferObject(StockModel c)
        {
            if (c == null) return null;

            return new StockDto
            {
                StockId = c.StockId,
                StockCode = c.StockCode,
                StockName = c.StockName,
                Description = c.Description,
                IsActive = c.IsActive,
                UnitId = c.UnitId
            };
        }

        public static InventoryItemDto ToDataTransferObject(InventoryItemModel c)
        {
            if (c == null) return null;

            return new InventoryItemDto
            {
                InventoryItemId = c.InventoryItemId,
                InventoryItemName = c.InventoryItemName,
                InventoryItemCode = c.InventoryItemCode,
                AccountCode = c.AccountCode,
              //  CurrencyCode = entity.CurrencyCode,
                IsActive = c.IsActive,
              //  CostMethod = entity.CostMethod,
                Unit = c.Unit,
                UnitId = c.UnitId
            };
        }


        /// <summary>
        /// Froms the data transfer object.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        internal static AccountDto ToDataTransferObject(AccountModel c) 
        {
            if (c == null) return null;

            return new AccountDto
            {
                AccountId = c.AccountId,
                UnitId = c.UnitId,
                AccountCode = c.AccountCode,
                AccountName = c.AccountName,
                ParentId = c.ParentId,
                Grade = c.Grade,
                IsDetail = c.IsDetail,
                Description = c.Description,
                IsCustomer = c.IsCustomer,
                IsVendor = c.IsVendor,
                IsTax = c.IsTax,
                IsInventoryItem = c.IsInventoryItem,
                IsFixedAsset = c.IsFixedAsset,
                IsActive = c.IsActive,
                IsSystem = c.IsSystem,
                BalanceSide = c.BalanceSide,
            };
        }
       
        /// <summary>
        /// 
        /// </summary>
        /// <param name="c"></param>
        /// <returns></returns>
        public static EmployTestDto ToDataTransferObject(EmployTestModel c)
        {
            if (c == null) return null;

            return new EmployTestDto
            {
                EmployId = c.EmployId,
                Name = c.Name,
                Salary = c.Salary,
                DepartmentId = c.DepartmentId
            };
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="c"></param>
        /// <returns></returns>
        public static ReportListDto ToDataTransferObject(ReportListModel c)
        {
            if (c == null) return null;

            return new ReportListDto
            {
                Description = c.Description,
                File = c.File,
                FunctionReportName = c.FunctionReportName,
                Grade = c.Grade,
                InputTypeName = c.InputTypeName,
                IsActive = c.IsActive,
                IsTypical = c.IsTypical,
                Name = c.Name,
                ProcedureReportName = c.ProcedureReportName,
                ReportGroupId = c.ReportGroupId,
                ReportListId = c.ReportListId,
                SortOrder = c.SortOrder,
                TableName = c.TableName,
                Code = c.Code,
                ReportController = c.ReportController,
                ParentId = c.ParentId
            };
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="c"></param>
        /// <returns></returns>
        public static ReportGroupDto ToDataTransferObject(ReportGroupModel c)
        {
            if (c == null) return null;

            return new ReportGroupDto
            {
                ReportGroupId = c.ReportGroupID,
                Name = c.ReportGroupName,
                Description = c.Description,
                IsVoucher = c.IsVoucher,
                IsActive = c.IsActive,
                IsTypical = c.IsTypical
            };
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="c"></param>
        /// <returns></returns>
        public static FixedAssetDto ToDataTransferObject(FixedAssetModel c)
        {
            if (c == null) return null;

            return new FixedAssetDto
            {
                FixedAssetId = c.FixedAssetId,
                FixedAssetCode = c.FixedAssetCode,
                FixedAssetName = c.FixedAssetName,
                FixedAssetForeignName = c.FixedAssetForeignName,
                FixedAssetCategoryId = c.FixedAssetCategoryId,
                State = c.State,
                Description = c.Description,
                ProductionYear = c.ProductionYear,
                MadeIn = c.MadeIn,
                PurchasedDate = c.PurchasedDate,
                UsedDate = c.UsedDate,
                DepreciationDate = c.DepreciationDate,
                IncrementDate = c.IncrementDate,
                DisposedDate = c.DisposedDate,
                Unit = c.Unit,
                SerialNumber = c.SerialNumber,
                Accessories = c.Accessories,
                Quantity = c.Quantity,
                UnitPrice = c.UnitPrice,
                OrgPrice = c.OrgPrice,
                AccumDepreciationAmount = c.AccumDepreciationAmount,
                RemainingAmount = c.RemainingAmount,
                AnnualDepreciationAmount = c.AnnualDepreciationAmount,
                LifeTime = c.LifeTime,
                DepreciationRate = c.DepreciationRate,
                OrgPriceAccountCode = c.OrgPriceAccountCode,
                DepreciationAccountCode = c.DepreciationAccountCode,
                CapitalAccountCode = c.CapitalAccountCode,
                DepartmentId = c.DepartmentId,
                EmployeeId = c.EmployeeId,
                IsActive = c.IsActive,
                CapitalMoneyAccountCode = c.CapitalMoneyAccountCode,
                ExpenseAccountCode = c.ExpenseAccountCode,
                UnitId = c.UnitId
            };
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="c"></param>
        /// <returns></returns>
        public static FixedAssetCategoryDto ToDataTransferObject(FixedAssetCategoryModel c)
        {
            if (c == null) return null;

            return new FixedAssetCategoryDto
            {
                FixedAssetCategoryId = c.FixedAssetCategoryId,
                ParentId = c.ParentId,
                FixedAssetCategoryCode = c.FixedAssetCategoryCode,
                FixedAssetCategoryName = c.FixedAssetCategoryName,
                DepreciationRate = c.DepreciationRate,
                LifeTime = c.LifeTime,
                Grade = c.Grade,
                IsParent = c.IsParent,
                OrgPriceAccountCode = c.OrgPriceAccountCode,
                DepreciationAccountCode = c.DepreciationAccountCode,
                CapitalAccountCode = c.CapitalAccountCode,
                IsActive = c.IsActive
            };
        }
        #endregion

        #region FromDataTransferObject
        /// <summary>
        /// 
        /// </summary>
        /// <param name="c"></param>
        /// <returns></returns>
        public static DepartmentModel FromDataTransferObject(DepartmentDto c)
        {
            if (c == null) return null;

            return new DepartmentModel
            {
                DepartmentId = (int)c.DepartmentId,
                UnitId = c.UnitId,
                Code = c.Code,
                Name = c.Name,
                Address = c.Address,
                Description = c.Description,
                IsActive = c.IsActive,
                Fax = c.Fax,
                PhoneNumber = c.PhoneNumber,
                ParentId = c.ParentId,
            };
        }
        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <returns></returns>
        public static UnitModel FromDataTransferObject(UnitDto c)
        {
            if (c == null) return null;
            return new UnitModel
            {
                UnitId = (int)c.UnitId,
                ParentId = c.ParentId ,
                
                Code = c.Code,
                Name = c.Name,
                Grade = c.Grade,
                IsActive = c.IsActive,
                HasParent = c.HasParent,
                PhoneNumber = c.PhoneNumber,
                Address = c.Address,
                ByManagement = c.ByManagement,
            };
        }

        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <returns></returns>
        public static CustomerModel FromDataTransferObject(CustomerDto c)
        {
            return new CustomerModel
            {
                CustomerId = c.CustomerId,
                UnitId = c.UnitId,
                Code = c.Code,
                Name = c.Name,
                Address = c.Address,
                PhoneNumber = c.PhoneNumber,
                Fax = c.Fax,
                CompanyName = c.CompanyName,
                ContactName = c.ContactName,
                Description = c.Description,
                IsActive = c.IsActive,
            };
        }

        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <returns></returns>
        public static VendorModel FromDataTransferObject(VendorDto c)
        {
            return new VendorModel
            {
                VendorId = c.VendorId,
                Code = c.Code,
                Name = c.Name,
                Address = c.Address,
                ContactName = c.ContactName,
                PhoneNumber = c.PhoneNumber,
                Description = c.Description,
                Fax = c.Fax,
                IsActive = c.IsActive,
                UnitId = c.UnitId,
            };
        }


        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <returns></returns>
        public static VoucherTypeModel FromDataTransferObject(VoucherTypeDto c)
        {
            return new VoucherTypeModel
            {
                VoucherTypeId = c.VoucherTypeId,
                VoucherTypeName = c.VoucherTypeName,
                IsActive = c.IsActive
            };
        }

        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <returns></returns>
        public static AutoNumberModel FromDataTransferObject(AutoNumberDto c)
        {
            return new AutoNumberModel
            {
                AutoId = c.AutoId,
                UnitId = c.UnitId,
                LengthOfValue = c.LengthOfValue,
                Prefix = c.Prefix,
                RefTypeId = c.RefTypeId,
                Suffix = c.Suffix,
                Value = c.Value
            };
        }
        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <returns></returns>
        public static RefTypeModel FromDataTransferObject(RefTypeDto c)
        {
            return new RefTypeModel
            {
                RefTypeId = c.RefTypeId,
                MasterTable = c.MasterTable,
                Name = c.Name,
                DetailTable = c.DetailTable,
                Description = c.Description,
                IsActive = c.IsActive,
            };
        }


        /// <summary>
        /// Froms the data transfer object.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <returns></returns>
        public static AutoBusinessModel FromDataTransferObject(AutoBusinessDto c)
        {
            if (c == null) return null;

            return new AutoBusinessModel
            {
                AutoBusinessId = c.AutoBusinessId,
                AutoBusinessCode = c.AutoBusinessCode,
                AutoBusinessName = c.AutoBusinessName,
                RefTypeId = c.RefTypeId,
                VoucherTypeId = c.VoucherTypeId,
                DebitAccountNumber = c.DebitAccountNumber,
                CreditAccountNumber = c.CreditAccountNumber,
                // BudgetSourceCode = entity.BudgetSourceCode,
                // BudgetItemCode = entity.BudgetItemCode,
                Description = c.Description,
                IsActive = c.IsActive,
                UnitId = c.UnitId
            };
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="c"></param>
        /// <returns></returns>
        public static DbOptionModel FromDataTransferObject(DbOptionDto c)
        {
            if (c == null) return null;

            return new DbOptionModel
            {
                OptionId = c.OptionId,
                UnitId = c.UnitId,
                Code = c.Code,
                Value = c.Value,
                ValueType = c.ValueType,
                Description = c.Description,
                IsSystem = c.IsSystem
            };
        }

        public static StockModel FromDataTransferObject(StockDto c)
        {
            if (c == null) return null;

            return new StockModel
            {
                StockId = c.StockId,
                StockCode = c.StockCode,
                StockName = c.StockName,
                Description = c.Description,
                IsActive = c.IsActive,
                UnitId = c.UnitId
            };
        }

        public static InventoryItemModel FromDataTransferObject(InventoryItemDto c) 
        {
            if (c == null) return null;

            return new InventoryItemModel
            {
                InventoryItemId = c.InventoryItemId,
                InventoryItemName = c.InventoryItemName,
                InventoryItemCode = c.InventoryItemCode,
                AccountCode = c.AccountCode,
                //  CurrencyCode = entity.CurrencyCode,
                IsActive = c.IsActive,
                //  CostMethod = entity.CostMethod,
                Unit = c.Unit,
                UnitId = c.UnitId
            };
        }


      

        /// <summary>
        /// 
        /// </summary>
        /// <param name="dto"> </param>
        /// <returns></returns>
        public static EmployTestModel FromDataTransferObject(EmployTestDto dto)
        {
            if (dto == null) return null;

            return new EmployTestModel
            {
                EmployId = dto.EmployId,
                Name = dto.Name,
                Salary = dto.Salary,
                DepartmentId = dto.DepartmentId
            };
        }

        /// <summary>
        /// Froms the data transfer object.
        /// </summary>
        /// <param name="dto"> </param>
        /// <returns></returns>
        internal static AccountModel FromDataTransferObject(AccountDto dto)
        {
            if (dto == null) return null;

            return new AccountModel
            {
                AccountId = dto.AccountId,
                UnitId = dto.UnitId,
                AccountCode = dto.AccountCode,
                AccountName = dto.AccountName,
                ParentId = dto.ParentId,
                Grade = dto.Grade,
                IsDetail = dto.IsDetail,
                Description = dto.Description,
                IsCustomer = dto.IsCustomer,
                IsVendor = dto.IsVendor,
                IsTax = dto.IsTax,
                IsInventoryItem = dto.IsInventoryItem,
                IsFixedAsset = dto.IsFixedAsset,
                IsActive = dto.IsActive,
                IsSystem = dto.IsSystem,
                BalanceSide = dto.BalanceSide,
            };
        }

        /// <summary>
        /// Froms the data transfer object.
        /// </summary>
        /// <param name="dto"> </param>
        /// <returns></returns>
        internal static ReportListModel FromDataTransferObject(ReportListDto dto)
        {
            if (dto == null) return null;

            return new ReportListModel
            {
                Description = dto.Description,
                File = dto.File,
                FunctionReportName = dto.FunctionReportName,
                Grade = dto.Grade,
                InputTypeName = dto.InputTypeName,
                IsActive = dto.IsActive,
                IsTypical = dto.IsTypical,
                Name = dto.Name,
                ProcedureReportName = dto.ProcedureReportName,
                ReportGroupId = dto.ReportGroupId,
                ReportListId = dto.ReportListId,
                SortOrder = dto.SortOrder,
                TableName = dto.TableName,
                Code = dto.Code,
                ReportController = dto.ReportController,
                ParentId = dto.ParentId
            };
        }

        /// <summary>
        /// Froms the data transfer object.
        /// </summary>
        /// <param name="dto"> </param>
        /// <returns></returns>
        internal static ReportGroupModel FromDataTransferObject(ReportGroupDto dto)
        {
            if (dto == null) return null;

            return new ReportGroupModel
            {
                ReportGroupID = dto.ReportGroupId,
                ReportGroupName = dto.Name,
                Description = dto.Description,
                IsVoucher = dto.IsVoucher,
                IsActive = dto.IsActive,
                IsTypical = dto.IsTypical
            };
        }

        /// <summary>
        /// Froms the data transfer object.
        /// </summary>
        /// <param name="dto"> </param>
        /// <returns></returns>
        internal static FixedAssetModel FromDataTransferObject(FixedAssetDto dto)
        {
            if (dto == null) return null;

            return new FixedAssetModel
            {
                FixedAssetId = dto.FixedAssetId,
                FixedAssetCode = dto.FixedAssetCode,
                FixedAssetName = dto.FixedAssetName,
                FixedAssetForeignName = dto.FixedAssetForeignName,
                FixedAssetCategoryId = (int)dto.FixedAssetCategoryId,
                State = dto.State,
                Description = dto.Description,
                ProductionYear = dto.ProductionYear,
                MadeIn = dto.MadeIn,
                PurchasedDate = dto.PurchasedDate,
                UsedDate = dto.UsedDate,
                DepreciationDate = dto.DepreciationDate,
                IncrementDate = dto.IncrementDate,
                DisposedDate = dto.DisposedDate,
                Unit = dto.Unit,
                SerialNumber = dto.SerialNumber,
                Accessories = dto.Accessories,
                Quantity = dto.Quantity,
                UnitPrice = dto.UnitPrice,
                OrgPrice = dto.OrgPrice,
                AccumDepreciationAmount = dto.AccumDepreciationAmount,
                RemainingAmount = dto.RemainingAmount,
                AnnualDepreciationAmount = dto.AnnualDepreciationAmount,
                LifeTime = dto.LifeTime,
                DepreciationRate = dto.DepreciationRate,
                OrgPriceAccountCode = dto.OrgPriceAccountCode,
                DepreciationAccountCode = dto.DepreciationAccountCode,
                CapitalAccountCode = dto.CapitalAccountCode,
                DepartmentId = dto.DepartmentId,
                EmployeeId = dto.EmployeeId,
                IsActive = dto.IsActive,
                CapitalMoneyAccountCode = dto.CapitalMoneyAccountCode,
                ExpenseAccountCode = dto.ExpenseAccountCode,
                UnitId = dto.UnitId
            };
        }

        /// <summary>
        /// Froms the data transfer object.
        /// </summary>
        /// <param name="dto"> </param>
        /// <returns></returns>
        internal static FixedAssetCategoryModel FromDataTransferObject(FixedAssetCategoryDto dto)
        {
            if (dto == null) return null;

            return new FixedAssetCategoryModel
            {
                FixedAssetCategoryId = (int)dto.FixedAssetCategoryId,
                ParentId = dto.ParentId,
                FixedAssetCategoryCode = dto.FixedAssetCategoryCode,
                FixedAssetCategoryName = dto.FixedAssetCategoryName,
                DepreciationRate = dto.DepreciationRate,
                LifeTime = dto.LifeTime,
                Grade = dto.Grade,
                IsParent = dto.IsParent,
                OrgPriceAccountCode = dto.OrgPriceAccountCode,
                DepreciationAccountCode = dto.DepreciationAccountCode,
                CapitalAccountCode = dto.CapitalAccountCode,
                IsActive = dto.IsActive,
                UnitId = dto.UnitId
            };
        }

        public static StockBacklogModel FromDataTransferObject(StockBacklogDto dto)
        {
            if (dto == null) return null;

            return new StockBacklogModel
            {
                InventoryItemCode = dto.InventoryItemCode,
                InventoryItemName = dto.InventoryItemName,
                Unit = dto.Unit,
                QuantityOpening = dto.QuantityOpening,
                QuantityInwardStock = dto.QuantityInwardStock,
                QuantityOutwardStock = dto.QuantityOutwardStock,
                QuantityClosing = dto.QuantityClosing,

                OrgPriceClosing = dto.OrgPriceClosing,
                OrgPriceInwardStock = dto.OrgPriceInwardStock,
                OrgPriceOpening = dto.OrgPriceOpening,
                OrgPriceOutwardStock = dto.OrgPriceOutwardStock,
            };
        }
        #endregion

        #region FromDataTransferObjects
        /// <summary>
        /// Froms the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<DepartmentModel> FromDataTransferObjects(IEnumerable<DepartmentDto> c)
        {
            return c == null ? null : c.Select(source => FromDataTransferObject((source))).ToList();
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static IList<UnitModel> FromDataTransferObjects(IEnumerable<UnitDto> c)
        {
            return c == null ? null : c.Select(source => FromDataTransferObject((source))).ToList();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static IList<CustomerModel> FromDataTransferObjects(IEnumerable<CustomerDto> c)
        {
            return c == null ? null : c.Select(source => FromDataTransferObject((source))).ToList();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static IList<VendorModel> FromDataTransferObjects(IEnumerable<VendorDto> c)
        {
            return c == null ? null : c.Select(source => FromDataTransferObject((source))).ToList();
        }


        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static IList<VoucherTypeModel> FromDataTransferObjects(IEnumerable<VoucherTypeDto> c)
        {
            return c == null ? null : c.Select(source => FromDataTransferObject((source))).ToList();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static IList<RefTypeModel> FromDataTransferObjects(IEnumerable<RefTypeDto> c)
        {
            return c == null ? null : c.Select(source => FromDataTransferObject((source))).ToList();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="dbOptions"></param>
        /// <returns></returns>
        public static IList<AutoBusinessModel> FromDataTransferObjects(IEnumerable<AutoBusinessDto> c)
        {
            return c == null ? null : c.Select(source => FromDataTransferObject((source))).ToList();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="dbOptions"></param>
        /// <returns></returns>
        public static IList<DbOptionModel> FromDataTransferObjects(IEnumerable<DbOptionDto> c)
        {
            return c == null ? null : c.Select(source => FromDataTransferObject((source))).ToList();
        }

        /// <summary>
        /// Froms the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<StockModel> FromDataTransferObjects(IEnumerable<StockDto> c)
        {
            return c == null ? null : c.Select(source => FromDataTransferObject((source))).ToList();
        }

        /// <summary>
        /// Froms the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<InventoryItemModel> FromDataTransferObjects(IEnumerable<InventoryItemDto> c)
        {
            return c == null ? null : c.Select(source => FromDataTransferObject((source))).ToList();
        }

        /// <summary>
        /// Froms the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<AccountModel> FromDataTransferObjects(IEnumerable<AccountDto> c)
        {
            return c == null ? null : c.Select(source => FromDataTransferObject((source))).ToList();
        }

        /// <summary>
        /// Froms the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<EmployTestModel> FromDataTransferObjects(IEnumerable<EmployTestDto> c)
        {
            return c == null ? null : c.Select(source => FromDataTransferObject((source))).ToList();
        }

      

        /// <summary>
        /// Froms the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static List<ReportListModel> FromDataTransferObjects(IEnumerable<ReportListDto> c)
        {
            return c == null ? null : c.Select(source => FromDataTransferObject((source))).ToList();
        }

        ///// <summary>
        ///// Froms the data transfer objects.
        ///// </summary>
        ///// <param name="c">The c.</param>
        ///// <returns></returns>
        //public static List<ReportGroupModel> FromDataTransferObjects(IEnumerable<ReportGroupDto> c)
        //{
        //    return c == null ? null : c.Select(source => FromDataTransferObject((source))).ToList();
        //}
        
        public static List<ReportGroupModel> FromDataTransferObject(IEnumerable<ReportGroupDto> c)
        {
            return c == null ? null : c.Select(source => FromDataTransferObject((source))).ToList();
        }

        //public static List<FixedAssetModel> FromDataTransferObject(IEnumerable<FixedAssetDto> c)
        //{
        //    return c == null ? null : c.Select(source => FromDataTransferObject((source))).ToList();
        //}

        //public static List<FixedAssetCategoryModel> FromDataTransferObject(IEnumerable<FixedAssetCategoryDto> c)
        //{
        //    return c == null ? null : c.Select(source => FromDataTransferObject((source))).ToList();
        //}

        /// <summary>
        /// Froms the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<FixedAssetModel> FromDataTransferObjects(IEnumerable<FixedAssetDto> c)
        {
            return c == null ? null : c.Select(source => FromDataTransferObject((source))).ToList();
        }

        /// <summary>
        /// Froms the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<FixedAssetCategoryModel> FromDataTransferObjects(IEnumerable<FixedAssetCategoryDto> c)
        {
            return c == null ? null : c.Select(source => FromDataTransferObject((source))).ToList();
        }

        public static IList<StockBacklogModel> FromDataTransferObjects(IEnumerable<StockBacklogDto> c)
        {
            return c == null ? null : c.Select(source => FromDataTransferObject((source))).ToList();
        }
        #endregion
        
    }
}